from flask import Flask,request


# 创建服务器实例
app = Flask(__name__)


#开启debug模式，更新代码不用重启服务
app.debug = True

#http://localhost:8000/
@app.route('/',methods=['GET','POST'])
def index():
    return """IS HOME~~"""

#http://localhost:8000/hello/aaa
@app.route('/hello/aaa',methods=['GET','POST'])
def aaa():
    return """IS AAA~~"""
    

#http://localhost:8000/hello
@app.route('/hello',methods=['GET','POST'])
def hello():

    name = 'aa'
    pwd = 'bbb'
    if request.method == 'POST':
        name = request.form['name']
        pwd = request.form['pwd']
    
    
    return """
        <h1>用户登录的信息</h1>
        <form action="" method="post">
            <input name="name" plachol="用户名"></br>
            <input name="pwd" plachol="口令"></br>
            <button>提交</button>
        </form>
        <h1>用户名：%s</h1>
        <h1>口令：%s</h1>
    """ % (name, pwd)

 
#http://localhost:8000/url/12333/http://www.baidu.com
@app.route('/url/<path:uu>/<username>')
def urltest(username,uu):
    return """
        username:%s<br />
        uu:%s
    """ % (username, uu)


@app.route('/url/<path:uu>/<username>')
def html_templete(username,uu):
    return """
        username:%s<br />
        uu:%s
    """ % (username, uu)



# 启动服务器
app.run(host="localhost",port="8000")